using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using AtletIS.DomainModel.Entities.Web;

namespace AtletIS.Database.Mapping.Web
{
    public class LinkMap : EntityTypeConfiguration<Link>
    {
        public LinkMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.Name)
                .HasMaxLength(100);

            this.Property(t => t.Adress)
                .HasMaxLength(255);

            this.Property(t => t.LogoPath)
                .HasMaxLength(255);

            // Table & Column Mappings
            this.ToTable("Links");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.CategoryId).HasColumnName("CategoryId");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.Order).HasColumnName("Order");
            this.Property(t => t.Adress).HasColumnName("Adress");
            this.Property(t => t.LogoPath).HasColumnName("LogoPath");
            this.Property(t => t.Active).HasColumnName("Active");

            // Relationships
            this.HasOptional(t => t.LinksCategory)
                .WithMany(t => t.Links)
                .HasForeignKey(d => d.CategoryId);

        }
    }
}
